package com.czg.jsonschema2lombokpojo;

/**
 * Url协议类型
 */
public enum URLProtocol {
    FILE("file"),
    RESOURCE("resource"),
    JAVA("java"),
    CLASSPATH("classpath"),
    HTTP("http"),
    HTTPS("https"),
    NO_PROTOCOL("");

    private String protocol;

    URLProtocol(final String protocol) {
        this.protocol = protocol;
    }

    public String getProtocol() {
        return protocol;
    }

    public static URLProtocol fromString(final String input) {
        for (URLProtocol protocol : URLProtocol.values()) {
            if (protocol.getProtocol().equalsIgnoreCase(input)) {
                return protocol;
            }
        }
        // default to file
        return NO_PROTOCOL;
    }
}
